/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SComplaintConverter.java
 * Created：		2016年8月21日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.complaint.converter;

import java.util.Date;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.OperateInfoToBeanConverter;
import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.common.AWorkOrderConverter;
import com.thor.palmmall.rest.complaint.AComplaint;
import com.thor.palmmall.rest.repair.converter.SWorkOrderConverter;
import com.thor.palmmall.spi.common.SOperateInfoConverter;
import com.thor.palmmall.spi.complaint.SComplaint;

/**
 * @author wolv
 *
 */
public class SComplaintConverter implements Converter<AComplaint,SComplaint> {

  public static SComplaintConverter getInstance() {
    if (instance == null)
      instance = new SComplaintConverter();
    return instance;
  }

  private static SComplaintConverter instance;

  private SComplaintConverter() {
  }

  @Override
  public SComplaint convert(AComplaint source) {
    if (source == null)
      return null;

    SComplaint target = new SComplaint();
    target.setBillNumber(source.getBillNumber());
    target.setBizState(source.getBizState());
    target.setComplainant(UCN.newInstance(source.getComplainant()));
    target.setComplaintContents(source.getComplaintContents());
    if (source.getComplaintGrade() != null){
      target.setComplaintGrade(source.getComplaintGrade());
    }
//      target.setComplaintLevel(AComplaintLevel.valueOf(source.getComplaintGrade().name()));
    target.setComplaintSource(source.getComplaintSource().name());
    target.setContactInfo(source.getContactInfo());
    target.setHappenTime(source.getHappenTime());
    target.setPermGroupId(source.getPermGroupId());
    target.setPermGroupTitle(source.getPermGroupTitle());
    target.setProcessInfo(source.getProcessInfo());
    target.setProcessLimitedTime(source.getProcessLimitedTime());
    target.setProcessPerson(UCN.newInstance(source.getProcessPerson()));
    target.setSourceClerk(UCN.newInstance(source.getSourceClerk()));
    target.setSourceContract(UCN.newInstance(source.getSourceContract()));
    target.setSourceTenant(UCN.newInstance(source.getSourceTenant()));
    target.setStore(UCN.newInstance(source.getStore()));
    target.setUuid(source.getUuid());
    target.setVersion(source.getVersion());
    target.setCreateInfo(SOperateInfoConverter.getInstance()
        .convert(OperateInfoToBeanConverter.getInstance().convert(source.getCreateInfo())));
    target.setLastModifyInfo(SOperateInfoConverter.getInstance()
        .convert(OperateInfoToBeanConverter.getInstance().convert(source.getLastModifyInfo())));
    target.setAbortMsg(source.getAbortMsg());
    target.setComplaintObject(source.getComplaintObject());
    target.setObjectTenant(source.getObjectTenant());
    target.setComplaintObject(source.getComplaintObject());
    target.setObjectTenant(source.getObjectTenant());
    target.setObjectContract(source.getObjectContract());
    target.setObjectClerk(UCN.newInstance(source.getObjectClerk()));
    target.setType(source.getType());
    target.setComplaintType(source.getComplaintType());
    target.setHandler(source.getHandler());
    target.setRemark(source.getRemark());
    target.setWorkOrder(SWorkOrderConverter.getInstance().convert(source.getWorkOrder()));
    target.setProcessEffect(source.getProcessEffect());
    target.setSolveInfo(source.getSolveInfo());
    target.setEvaluateUser(UCN.newInstance(source.getEvaluateUser()));
    target.setEvaluateTime(source.getEvaluateTime());
    target.setSubmitTime(source.getSubmitTime());
    target.setDealTime(source.getDealTime());
    target.setDealUser(source.getDealUser());
    target.setFinishTime(source.getFinishTime());
    
    return target;
  }
}
